package com.itic.web.question.questionmodel.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.itic.appbase.applications.sys.common.service.OutCommonService;
import com.itic.appbase.framework.common.constants.DBConst;
import com.itic.appbase.framework.common.constants.ResponseCode;
import com.itic.appbase.framework.plugins.mybatis.Page;
import com.itic.appbase.framework.utils.IdGen;
import com.itic.appbase.framework.utils.StringHelper;
import com.itic.demo.modelfiles.service.ModelFilesService;
import com.itic.ht.cms.exam.persistence.model.Exam;
import com.itic.ht.cms.exam.persistence.model.ExamExample;
import com.itic.ht.cms.exam.service.ExamService;
import com.itic.ht.cms.examrecord.persistence.model.ExamQuestion;
import com.itic.ht.cms.examrecord.persistence.model.ExamQuestionExample;
import com.itic.ht.cms.examrecord.persistence.model.ExamRecord;
import com.itic.ht.cms.examrecord.persistence.model.ExamRecordExample;
import com.itic.ht.cms.examrecord.persistence.model.ExamSchedule;
import com.itic.ht.cms.examrecord.persistence.model.ExamScheduleExample;
import com.itic.ht.cms.examrecord.service.ExamQuestionService;
import com.itic.ht.cms.examrecord.service.ExamRecordService;
import com.itic.ht.cms.examrecord.service.ExamScheduleService;
import com.itic.ht.cms.question.persistence.model.QuestionModel;
import com.itic.ht.cms.question.persistence.model.QuestionModelExample;
import com.itic.ht.cms.question.service.QuestionModelService;
import com.itic.ht.cms.questionselection.persistence.model.QuestionSelection;
import com.itic.ht.cms.questionselection.persistence.model.QuestionSelectionExample;
import com.itic.ht.cms.questionselection.service.QuestionSelectionService;
import com.itic.ht.cms.questype.persistence.model.QuestionType;
import com.itic.ht.cms.questype.persistence.model.QuestionTypeExample;
import com.itic.ht.cms.questype.service.QuestionTypeService;
import com.itic.ht.mem.member.persistence.model.WebMember;
import com.itic.ht.mem.member.service.WebMemberService;
import com.itic.ht.mem.pointwater.persistence.model.WebPointWater;
import com.itic.web.mem.pointwater.service.AppPointWaterService;
import com.itic.web.qo.TokenData;
import com.itic.web.ro.PageInfo;
import com.itic.web.ro.ResResult;
import com.itic.web.util.TokenUtil;

@Service
@Transactional
public class AppQuestionService {

	@Autowired
	private WebMemberService webMemberService;
	@Autowired
	private ModelFilesService modelFilesService;
	@Autowired
	protected QuestionTypeService questionTypeService;
	@Autowired
	protected QuestionModelService questionModelService;
	@Autowired
	protected QuestionSelectionService questionSelectionService;
	@Autowired
	private ExamService examService;
	@Autowired
	private ExamRecordService examRecordService;
	@Autowired
	protected OutCommonService outCommonService;
	@Autowired
	private ExamQuestionService examQuestionService;
	@Autowired
	private ExamScheduleService examScheduleService;
	@Autowired
    private AppPointWaterService appPointWaterService;

	public ResResult getTypeList(TokenData data) {

		WebMember member = null;
		try {
			// 判断token是不是存在
			if (StringHelper.isEmpty(data.getToken())) {
				return ResResult.error(1, "token不能为空");
			}
			// 先判断token正确性
			boolean flag = TokenUtil.assertUserToken(data);
			if (!flag) {
				return ResResult.error(2, "token失效");
			}

			// 初始化返回值
			Map<String, Object> datas = new HashMap<String, Object>();

			// 从token中取account信息
			data.setAccount(TokenUtil.getUserList(data.getToken()).getAccount().trim());
			// 取得用户信息
			member = webMemberService.getMemberByAccount(data.getAccount());
			System.out.println("查询到的用户帐号是" + member.getAccount());

			// 获取数据
			QuestionTypeExample typeExample = new QuestionTypeExample();
			typeExample.setOrderByClause("REORDER ASC");
			typeExample.createCriteria().andIsEffectiveEqualTo(DBConst.TRUE).andParentIdEqualTo(DBConst.FALSE);

			List<QuestionType> typelist = questionTypeService.list(typeExample);
			/*for (QuestionType queType : typelist) {
				String fileId = queType.getFileId();
				if (fileId != null && !"".equals(fileId)) {
					queType.setFileId(modelFilesService.getFile(fileId).getFilePath());
				}
			}*/

			member.setPassword(null);
			member.setExpireTime(null);
			member.setVerificationCode(null);
			member.setVerificationExpireTime(null);

			datas.put("member", member);
			datas.put("QuestionTypes", typelist);

			return ResResult.build(200, "问题列表查询成功", datas);
		} catch (Exception e) {
			// 返回错误代码
			e.printStackTrace();
			return ResResult.error(4, "问题列表查询失败");
		}

	}

	public ResResult getStudyInfo(TokenData data, String CategoryId) {

		WebMember member = null;
		try {
			// 判断token是不是存在
			if (StringHelper.isEmpty(data.getToken())) {
				return ResResult.error(1, "token不能为空");
			}
			if( StringHelper.isEmpty(CategoryId)){
				return ResResult.error(1, "categoryId不能为空");
			}
			// 先判断token正确性
			boolean flag = TokenUtil.assertUserToken(data);
			if (!flag) {
				return ResResult.error(2, "token失效");
			}

			// 初始化返回值
			Map<String, Object> datas = new HashMap<String, Object>();

			// 从token中取account信息
			data.setAccount(TokenUtil.getUserList(data.getToken()).getAccount().trim());
			// 取得用户信息
			member = webMemberService.getMemberByAccount(data.getAccount());
			System.out.println("查询到的用户帐号是" + member.getAccount());

			QuestionType modelByType = questionTypeService.get(CategoryId);

			// 先查问题1
			List<Map<String, Object>> resList = new ArrayList<>();
			

			QuestionModelExample questionExample = new QuestionModelExample();
			questionExample.setOrderByClause("REORDER ASC");
			questionExample.createCriteria().andIsEffectiveEqualTo(DBConst.TRUE)
					.andCategoryIdEqualTo(modelByType.getId());

			List<QuestionModel> questionList = questionModelService.list(questionExample);
			if (questionList != null && questionList.size() > 0) {
				for (QuestionModel questionModel : questionList) {
					Map<String, Object> resMap = new HashMap<>();
					//String fileId = questionModel.getFileId();
					/*if (fileId != null && !"".equals(fileId)) {
						questionModel.setFileId(modelFilesService.getFile(fileId).getFilePath());
					}*/
					// 根据问题查询选项 查询提示
					if (questionModel != null) {
						QuestionSelectionExample questionSelectionExample = new QuestionSelectionExample();
						questionSelectionExample.setOrderByClause("REORDER ASC");
						questionSelectionExample.createCriteria().andIsEffectiveEqualTo(DBConst.TRUE)
								.andQuestionIdEqualTo(questionModel.getId());
						List<QuestionSelection> selectlist = questionSelectionService.list(questionSelectionExample);
						List<QuestionSelection> questionSelectionList =new ArrayList<QuestionSelection>();
						QuestionSelection selectResult = null;
						for (int i=0;i<selectlist.size();i++) {
							Map<String, Object> qsMap = new HashMap<>();
							if (selectlist.get(i).getSelectType().equals("XX")) {
								/*//根据图片ID获取图片路径
								fileId = selectlist.get(i).getFileId();
								if(!"".equals(fileId)){
									String filePath = modelFilesService.getFile(fileId).getFilePath();
									selectlist.get(i).setFileId(filePath);
								}*/
								questionSelectionList.add(selectlist.get(i));
								
							}
							if (selectlist.get(i).getSelectType().equals("TS")) {
								selectResult = selectlist.get(i);
							}
							qsMap.put("TS", selectResult);
							qsMap.put("XX", questionSelectionList);
							resMap.put("questionSelections", qsMap);
						}
						if (null != questionModel.getId())resMap.put("id", questionModel.getId());
						if (null != questionModel.getFileId())resMap.put("fileId", questionModel.getFileId());
						if (null != questionModel.getName())resMap.put("name", questionModel.getName());
						if (null != questionModel.getStyleText())resMap.put("styleText", questionModel.getStyleText());
						if (null != questionModel.getSelectType())resMap.put("selectType", questionModel.getSelectType());
						if (null != questionModel.getCategory())resMap.put("category", questionModel.getCategory());
						resList.add(resMap);
					}
				}

			}

			datas.put("member", member);
			datas.put("question", resList);
			return ResResult.build(200, "学习列表查询成功", datas);
		} catch (Exception e) {
			// 返回错误代码
			e.printStackTrace();
			return ResResult.error(4, "学习列表查询失败");
		}

	}
	public ResResult getExamModel(TokenData data, String CategoryId,String isRandom){
		WebMember member = null;
		try {
			// 判断token是不是存在
			if (StringHelper.isEmpty(data.getToken())) {
				return ResResult.error(1, "token不能为空");
			}
			// 先判断token正确性
			boolean flag = TokenUtil.assertUserToken(data);
			if (!flag) {
				return ResResult.error(2, "token失效");
			}
			// 初始化返回值
			Map<String, Object> datas = new HashMap<String, Object>();
			List<Map<String, Object>> resList = new ArrayList<>();
			Map<String, Object> resMap = new HashMap<>();
			// 从token中取account信息
			data.setAccount(TokenUtil.getUserList(data.getToken()).getAccount().trim());
			// 取得用户信息
			member = webMemberService.getMemberByAccount(data.getAccount());
			// 先判断用户是否是会员
			if (!"eba618aea92c49dba49cc82d70be52b0".equals(member.getCategory()) && member.getExpireTime().after(new Date())) {
				//判断用户是否是第一次考试
				ExamScheduleExample example = new ExamScheduleExample();
				example.createCriteria().andAccountEqualTo(member.getAccount()).andDelFlgEqualTo(DBConst.TRUE);
				List<ExamSchedule> schedulelist = examScheduleService.getScheduleByAccount(example);
				ExamSchedule schedule  = null;
				if(schedulelist.size()>0&&schedulelist!=null){
					schedule = schedulelist.get(0);
				}
				if(schedule==null){
					//创建用户考试进度
					schedule = new ExamSchedule();
					schedule.setAccount(member.getAccount());
					schedule.setCtime(new Date());
					schedule.setMtime(new Date());
					schedule.setDelFlg(DBConst.TRUE);
					schedule.setSchedule(1);
					schedule.setId(IdGen.uuid());
					examScheduleService.add(schedule);
				}
				
				//根据当前用户考试进度取试卷题目
				ExamExample examep = new ExamExample();
				examep.setOrderByClause("REORDER ASC");
				examep.createCriteria().andDelFlagEqualTo(Integer.parseInt(DBConst.TRUE)).andCategoryIdEqualTo(CategoryId)
						.andReorderEqualTo(schedule.getSchedule());
				List<Exam> examlist = examService.list(examep);
				if(null==examlist){
					return ResResult.error(400, "该试卷不存在");
				}
				Exam exam = examlist.get(0);
				//根据试卷取试卷题目
				int progress = schedule.getSchedule()*DBConst.QUESTION_NUM;
				if(schedule.getSchedule()==1){
					progress =0;
				}
				List<QuestionModel> questionList = questionModelService.getExamQuestionList(progress, DBConst.QUESTION_NUM,exam.getCategoryId(),isRandom);
				if (null == questionList || questionList.size() < DBConst.QUESTION_NUM) {
					return ResResult.error(5, "当前分类暂无试卷");
				}
				
				for (QuestionModel qm : questionList) {
					Map<String, Object> resultMap = new HashMap<>();
					//String fileId = qm.getFileId();
					/*if (fileId != null && !"".equals(fileId)) {
						qm.setFileId(modelFilesService.getFile(fileId).getFilePath());
					}*/
					// 根据问题查询选项 查询提示
					if (qm != null) {
						QuestionSelectionExample questionSelectionExample = new QuestionSelectionExample();
						questionSelectionExample.setOrderByClause("REORDER ASC");
						questionSelectionExample.createCriteria().andIsEffectiveEqualTo(DBConst.TRUE)
								.andQuestionIdEqualTo(qm.getId());
						List<QuestionSelection> selectlist = questionSelectionService.list(questionSelectionExample);
						List<QuestionSelection> questionSelectionList =new ArrayList<QuestionSelection>();
						QuestionSelection selectResult = null;
						for (int i=0;i<selectlist.size();i++) {
							Map<String, Object> qsMap = new HashMap<>();
							if (selectlist.get(i).getSelectType().equals("XX")) {
								/*//根据图片ID获取图片路径
								fileId = selectlist.get(i).getFileId();
								if(!"".equals(fileId)){
									String filePath = modelFilesService.getFile(fileId).getFilePath();
									selectlist.get(i).setFileId(filePath);
								}*/
								questionSelectionList.add(selectlist.get(i));
								
							}
							if (selectlist.get(i).getSelectType().equals("TS")) {
								selectResult = selectlist.get(i);
							}
							qsMap.put("TS", selectResult);
							qsMap.put("XX", questionSelectionList);
							resultMap.put("questionSelections", qsMap);
						}
						if (null != qm.getId())resultMap.put("id", qm.getId());
						if (null != qm.getFileId())resultMap.put("fileId", qm.getFileId());
						if (null != qm.getName())resultMap.put("name", qm.getName());
						if (null != qm.getStyleText())resultMap.put("styleText", qm.getStyleText());
						if (null != qm.getSelectType())resultMap.put("selectType", qm.getSelectType());
						if (null != qm.getCategory())resultMap.put("category", qm.getCategory());

						resList.add(resultMap);
					}
				}
				resMap.put("questionModel", resList);
				if (null != exam.getId())
					resMap.put("id", exam.getId());
				if (null != exam.getExamName())
					resMap.put("examName", exam.getExamName());

				datas.put("member", member);
				datas.put("exam", resMap);
				return ResResult.build(200, "获取考题成功", datas);
			}else{
				return ResResult.error(4, "您没有权限考试，请先购买会员");
			}
		} catch (Exception e) {
			// 返回错误代码
			e.printStackTrace();
			return ResResult.error(4, "获取考题失败");
		}
	}

	/*public ResResult getExamModel(TokenData data, String CategoryId) {

		WebMember member = null;
		try {
			// 判断token是不是存在
			if (StringHelper.isEmpty(data.getToken())) {
				return ResResult.error(1, "token不能为空");
			}
			// 先判断token正确性
			boolean flag = TokenUtil.assertUserToken(data);
			if (!flag) {
				return ResResult.error(2, "token失效");
			}

			// 从token中取account信息
			data.setAccount(TokenUtil.getUserList(data.getToken()).getAccount().trim());
			// 取得用户信息
			member = webMemberService.getMemberByAccount(data.getAccount());
			System.out.println("查询到的用户帐号是" + member.getAccount());
			// 先判断用户是否是会员
			if ("eba618aea92c49dba49cc82d70be52b0".equals(member.getCategory())) {
				return ResResult.error(4, "您没有权限考试，请先购买会员");
			}

			// 初始化返回值
			Map<String, Object> datas = new HashMap<String, Object>();
			// 查询考试记录库有没有模拟考试不过的记录 ======= 如果有则返回记录中的考试ID 不再得新生成
			// ##############在数据库中添加成功和失败的字段 -有成功的就可以生成新试卷
			ExamRecordExample example = new ExamRecordExample();
			example.createCriteria().andAccountEqualTo(member.getAccount()).andExamResultEqualTo(DBConst.FALSE);
			List<ExamRecord> list = examRecordService.list(example);
			int progress = 1;

			if (null != list && list.size() > 0) {
				ExamRecord examRecord = list.get(0);
				progress = (Integer.parseInt(examRecord.getExamProgress())-1) * DBConst.QUESTION_NUM;
			}
			// 如无失败考试记录 = 生成新的考试记录ID 记录场次为1
			// 根据用户考试进度取试卷数据
			ExamExample examep = new ExamExample();
			examep.setOrderByClause("reorder asc");
			examep.createCriteria().andDelFlagEqualTo(Integer.parseInt(DBConst.TRUE)).andCategoryIdEqualTo(CategoryId)
					.andReorderEqualTo(progress+1);
			List<Exam> examlist = examService.list(examep);
			if (null == examlist || examlist.size() == 0) {
				return ResResult.error(5, "当前分类暂无试卷");
			}
			List<Map<String, Object>> resList = new ArrayList<>();
			Map<String, Object> resMap = new HashMap<>();
			Exam exam = examlist.get(0);
			// 查询对应试卷的题目
			List<QuestionModel> questionList = questionModelService.getExamQuestionList(progress, DBConst.QUESTION_NUM,exam.getCategoryId());
			if (null == questionList || questionList.size() < DBConst.QUESTION_NUM) {
				return ResResult.error(5, "当前分类暂无试卷");
			}
			
			for (QuestionModel qm : questionList) {
				Map<String, Object> resultMap = new HashMap<>();
				String fileId = qm.getFileId();
				if (fileId != null && !"".equals(fileId)) {
					qm.setFileId(modelFilesService.getFile(fileId).getFilePath());
				}
				// 根据问题查询选项 查询提示
				if (qm != null) {
					QuestionSelectionExample questionSelectionExample = new QuestionSelectionExample();
					questionSelectionExample.createCriteria().andIsEffectiveEqualTo(DBConst.TRUE)
							.andQuestionIdEqualTo(qm.getId());
					List<QuestionSelection> selectlist = questionSelectionService.list(questionSelectionExample);
					List<QuestionSelection> questionSelectionList =new ArrayList<QuestionSelection>();
					QuestionSelection selectResult = null;
					for (int i=0;i<selectlist.size();i++) {
						Map<String, Object> qsMap = new HashMap<>();
						if (selectlist.get(i).getSelectType().equals("XX")) {
							//根据图片ID获取图片路径
							fileId = selectlist.get(i).getFileId();
							if(!"".equals(fileId)){
								String filePath = modelFilesService.getFile(fileId).getFilePath();
								selectlist.get(i).setFileId(filePath);
							}
							questionSelectionList.add(selectlist.get(i));
							
						}
						if (selectlist.get(i).getSelectType().equals("TS")) {
							selectResult = selectlist.get(i);
						}
						qsMap.put("TS", selectResult);
						qsMap.put("XX", questionSelectionList);
						resultMap.put("questionSelections", qsMap);
					}
					if (null != qm.getId())resultMap.put("id", qm.getId());
					if (null != qm.getFileId())resultMap.put("fileId", qm.getFileId());
					if (null != qm.getName())resultMap.put("name", qm.getName());
					if (null != qm.getStyleText())resultMap.put("styleText", qm.getStyleText());
					if (null != qm.getSelectType())resultMap.put("selectType", qm.getSelectType());
					if (null != qm.getCategory())resultMap.put("category", qm.getCategory());

					resList.add(resultMap);
				}
			}
			resMap.put("questionModel", resList);
			if (null != exam.getId())
				resMap.put("id", exam.getId());
			if (null != exam.getExamName())
				resMap.put("examName", exam.getExamName());

			datas.put("member", member);
			datas.put("exam", resMap);
			return ResResult.build(200, "获取考题成功", datas);
		} catch (Exception e) {
			// 返回错误代码
			e.printStackTrace();
			return ResResult.error(4, "获取考题失败");
		}

	}*/

	public ResResult getExamInfo(TokenData data, String examId, Page page) {

		WebMember member = null;
		try {
			// 判断token是不是存在
			if (StringHelper.isEmpty(data.getToken())) {
				return ResResult.error(1, "token不能为空");
			}
			// 先判断token正确性
			boolean flag = TokenUtil.assertUserToken(data);
			if (!flag) {
				return ResResult.error(2, "token失效");
			}

			// 从token中取account信息
			data.setAccount(TokenUtil.getUserList(data.getToken()).getAccount().trim());
			// 取得用户信息
			member = webMemberService.getMemberByAccount(data.getAccount());
			System.out.println("查询到的用户帐号是" + member.getAccount());

			// 初始化返回值
			Map<String, Object> datas = new HashMap<String, Object>();
			// 根据试卷 和 分页数据 查询到中间表信息

			// 根据试题ID == 查询试题信息

			// 最后封装 试题信息 和 分页信息

			datas.put("member", member);
			return ResResult.build(200, "会员卡列表查询成功", datas);
		} catch (Exception e) {
			// 返回错误代码
			e.printStackTrace();
			return ResResult.error(4, "会员卡列表查询失败");
		}

	}

	public ResResult addExamWater(TokenData data, ExamQuestion examQuestion) {

		WebMember member = null;
		try {
			// 判断token是不是存在
			if (StringHelper.isEmpty(data.getToken())) {
				return ResResult.error(1, "token不能为空");
			}
			// 先判断token正确性
			boolean flag = TokenUtil.assertUserToken(data);
			if (!flag) {
				return ResResult.error(2, "token失效");
			}

			// 从token中取account信息
			data.setAccount(TokenUtil.getUserList(data.getToken()).getAccount().trim());
			// 取得用户信息
			member = webMemberService.getMemberByAccount(data.getAccount());
			System.out.println("查询到的用户帐号是" + member.getAccount());

			// 初始化返回值
			Map<String, Object> datas = new HashMap<String, Object>();
			// 添加考试试题记录流水。。
			examQuestion.setAccount(member.getAccount());
			examQuestion.setCtime(new Date());
			examQuestion.setMtime(new Date());
			examQuestion.setId(IdGen.uuid());
			examQuestion.setDelFlag(Integer.parseInt(DBConst.TRUE));

			// 根据题目Id查询具体的题目信息
			QuestionModel questionModel = questionModelService.get(examQuestion.getQuestionId());
			examQuestion.setQuestionName(questionModel.getName());
			// 获取题目对应的选项信息
			QuestionSelectionExample qmExample = new QuestionSelectionExample();
			qmExample.setOrderByClause("reorder asc");
			qmExample.createCriteria().andQuestionIdEqualTo(questionModel.getId());
			List<QuestionSelection> qsList = questionSelectionService.list(qmExample);
			for (QuestionSelection qs : qsList) {
				if ("TS".equals(qs.getSelectType())) {
					examQuestion.setQuestionAnalysis(qs.getStyleText());
				}
			}
			String result = ResponseCode.SERVER_ERROR.getCode();
			result = examQuestionService.add(examQuestion);
			datas.put("result", result);
			// 最后封装 试题信息 和 分页信息

			datas.put("member", member);
			return ResResult.build(200, "会员卡列表查询成功", datas);
		} catch (Exception e) {
			// 返回错误代码
			e.printStackTrace();
			return ResResult.error(4, "会员卡列表查询失败");
		}

	}

	public ResResult getExamResult(TokenData data, ExamRecord templet) {

		WebMember member = null;
		try {
			// 判断token是不是存在
			if (StringHelper.isEmpty(data.getToken())) {
				return ResResult.error(1, "token不能为空");
			}
			// 先判断token正确性
			boolean flag = TokenUtil.assertUserToken(data);
			if (!flag) {
				return ResResult.error(2, "token失效");
			}

			// 从token中取account信息
			data.setAccount(TokenUtil.getUserList(data.getToken()).getAccount().trim());
			// 取得用户信息
			member = webMemberService.getMemberByAccount(data.getAccount());
			System.out.println("查询到的用户帐号是" + member.getAccount());
			templet.setAccount(member.getAccount());

			// 初始化返回值
			Map<String, Object> datas = new HashMap<String, Object>();
			// 添加试卷结果信息
			String result = ResponseCode.SERVER_ERROR.getCode();
			result = examRecordService.add(templet);
			if(templet.getExamResult()=="1"){
				//增加用户考试进度
				ExamScheduleExample example = new ExamScheduleExample();
				example.createCriteria().andAccountEqualTo(member.getAccount()).andDelFlgEqualTo(DBConst.TRUE);
				List<ExamSchedule> schedulelist = examScheduleService.getScheduleByAccount(example);
				ExamSchedule schedule  = null;
				if(schedulelist.size()>0&&schedulelist!=null){
					schedule = schedulelist.get(0);
					schedule.setSchedule(schedule.getSchedule()+1);
					examScheduleService.edit(schedule);
				}
				//增加用户考试积分
				WebPointWater pointWater = new WebPointWater();
				pointWater.setItemId(templet.getExamId());
				pointWater.setCategory("002");
				appPointWaterService.add(pointWater, data);
			}
			//结果结果数据查询
			ExamQuestionExample example = new ExamQuestionExample();
			example.setOrderByClause("reorder asc");
			example.createCriteria().andAccountEqualTo(templet.getAccount()).andExamIdEqualTo(templet.getExamId()).andDelFlagEqualTo(Integer.parseInt(DBConst.TRUE));
			List<ExamQuestion> list = examQuestionService.list(example);
			
			datas.put("result", list);
			
			datas.put("member", member);
			return ResResult.build(200, "试卷结果保存成功", datas);
		} catch (Exception e) {
			// 返回错误代码
			e.printStackTrace();
			return ResResult.error(4, "试卷结果保存失败");
		}

	}

}
